//
//  TopBarView.m
//  WXD头标签
//
//  Created by mac on 17/7/1.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "TopBarView.h"

@implementation TopBarView
-(id)initWithFrame:(CGRect)frame{
    
    self=[super initWithFrame:frame];
    if (self) {
        tittle=[[UILabel alloc]initWithFrame:CGRectMake(self.frame.size.width/2-75, 20, 150, 40)];
        //tittle.text=@"首页";
        tittle.textAlignment=NSTextAlignmentCenter;
        [tittle setTextColor:[UIColor blackColor]];
        tittle.backgroundColor=self.backgroundColor;
        [self addSubview:tittle];
        
        back=[[UIButton alloc]initWithFrame:CGRectMake(10, 20, 23, 40)];
        
        [back setTitle:@"" forState:UIControlStateNormal];
        back.titleLabel.font = [UIFont systemFontOfSize: 13.0];
        [back addTarget:self action:@selector(backbtn:) forControlEvents:UIControlEventTouchDown];
        [back setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [self addSubview:back];
        
        add=[[UIButton alloc]initWithFrame:CGRectMake(self.frame.size.width-50, 20, 36, 36)];
        [add setTitle:@"添加" forState:UIControlStateNormal];
        [add addTarget:self action:@selector(addbtn) forControlEvents:UIControlEventTouchDown];
        [add setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        add.titleLabel.font = [UIFont systemFontOfSize: 14.0];
        //[self addSubview:add];
        
        
        
        line=[[UIView alloc]initWithFrame:CGRectMake(0, self.frame.size.height-1, self.frame.size.width, 1)];
        line.backgroundColor=[UIColor colorWithRed:220/255.0 green:220/255.0 blue:220/255.0 alpha:1.0];
        line.tag=1000;
        line.alpha=4;
        [self addSubview:line];
        
    }
    return self;
}
-(void)backbtn:(UIButton *)sender{
    if (_delegate&&[_delegate respondsToSelector:@selector(backActionOfdelegater)]) {
        [_delegate backActionOfdelegater];
    }
    else{
        NSLog(@"bb");
    }
}
-(void)addbtn{
    
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
-(void)setToptittle:(NSString *)Tittle{
   tittle.text=Tittle;
}
-(void)setTopTittleColor:(UIColor *)color{
    tittle.textColor=color;
}
-(void)setTopBgColor:(UIColor *)color{
    self.backgroundColor=color;
}
-(void)setBackBtnHide:(BOOL)hide{
    back.hidden=hide;
}
-(void)setBackBtnImage:(UIImage *)image{
    [back setBackgroundImage:image forState:UIControlStateNormal];
}
-(void)setTopLineHide:(BOOL)hide{
    line.hidden=hide;
}
-(void)setBackBtnTittle:(NSString *)btnTittle{
    [back setTitle:btnTittle forState:UIControlStateNormal];
}
@end
